<%-- 
    Document   : editPersonal
    Created on : Jun 14, 2012, 9:29:13 AM
    Author     : VANANH
--%>


<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<%@taglib prefix="rich" uri="http://richfaces.org/rich" %>
<%@taglib prefix="a4j" uri="http://richfaces.org/a4j" %>
<%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="../css/popup.css"/> 
        <link rel="stylesheet" type="text/css" href="../css/kapiform.css"/> 
        <script type="text/javascript" language="javascript" src="../scripts/jQuery/jq.date.js"></script>  
        <link rel="stylesheet" type="text/css" href="../css/ui.datepicker.css"/>
        <script type="text/javascript" language="javascript" src="../scripts/jQuery/kapi.js"></script>
        <script type="text/javascript">
            var open_cur = 0;
            $j = jQuery.noConflict();
            $j(document).ready(function(){   
             
                $j('input#dateStart,input#dateStart1, input#dateEnd1').datepicker({ dateFormat: 'dd/mm/yy', showOn: 'button', buttonImage: '../images/calenda_icon.gif', buttonImageOnly: true }); 
                $j('.passport, .cmnd, .place_of_issue, .place_of_issue1').attr('disabled', true);
                $j('input#dateStart1,input#dateEnd1,input#dateStart').datepicker("disable");
            
                if($j('.checkCmnd').is(':checked')){
                    $j('.cmnd, .place_of_issue').attr('disabled', false); 
                    $j(".alert2").text("");
                    $j('input#dateStart').datepicker("enable");
                }
                $j(".checkCmnd").live("click",function(){
              
                    if($j('.checkCmnd').is(':checked')){
                        $j('.cmnd, .place_of_issue').attr('disabled', false);
                        $j('.sumbitEmp').attr('disabled', false);
                        //$j(".alert2").text("");
                        $j('input#dateStart').datepicker("enable");
                    }else{
                        $j('.cmnd, .place_of_issue').attr('disabled', true); 
                        $j('.sumbitEmp').attr('disabled', true);
                        $j('input#dateStart').datepicker("disable");
                    }
                       
                }); 
                if($j('.checkPassport').is(':checked')){
                    $j('.passport, .place_of_issue1').attr('disabled', false); 
                    $j('.sumbitEmp').attr('disabled', false);
                    $j('input#dateStart1,input#dateEnd1').datepicker("enable");
                }
                $j(".checkPassport").live("click",function(){
              
                    if($j('.checkPassport').is(':checked')){
                        $j('.passport, .place_of_issue1').attr('disabled', false); 
                        $j('.sumbitEmp').attr('disabled', false);
                        $j('input#dateStart1,input#dateEnd1').datepicker("enable");
                    }else{
                        $j('.passport, .place_of_issue1').attr('disabled', true); 
                        $j('.sumbitEmp').attr('disabled', true);
                        $j('input#dateStart1,input#dateEnd1').datepicker("disable");
                    }
                       
                }); 
                
                // 
                // $j('#timepicker').timepicker();
                //   $j('#timepicker2').timepicker();               
                // $j('.sumbitEmp').attr('disabled', true);
                $j("#dateStart1").live("change",function(){
                    var DateToValue = process($j("#dateStart1").val());
                    var DateFromValue = process($j("#dateEnd1").val());
                    if(DateFromValue !=null){                        
                        if (DateToValue <= DateFromValue) {
                            $j(".alert").text("");
                            $j('.sumbitEmp').attr('disabled', false);
                   
                        }else{
                            $j('.sumbitEmp').attr('disabled', true);
                            $j(".alert").text("Chú ý: Ngày hết hạn phải lớn hơn ngày cấp");
                            $j("#dateEnd1").text("");
                        }
                        
                    }
                    $j( "#dateStart1" ).datepicker({ dateFormat: "dd/mm/yy" });
                });
                $j("#dateEnd1").live("change",function(){
                    var DateToValue = process($j("#dateStart1").val());
                    var DateFromValue = process($j("#dateEnd1").val());
                    
                    if (DateToValue <= DateFromValue) {
                        $j(".alert").text("");
                        $j('.sumbitEmp').attr('disabled', false);
                   
                    }else{
                        $j('.sumbitEmp').attr('disabled', true);
                        $j(".alert").text("Chú ý: Ngày hết hạn phải lớn hơn ngày cấp");
                        $j("#dateEnd1").text("");
                    }
                    $j( "#dateEnd1" ).datepicker({ dateFormat: "dd/mm/yy" });
                });
                var b = location.pathname;
                $j("input[id$='message']").val(b);
            
                validateform("personal");
       
                //                $j("#dateStart").live("change",function(){
                //                    var DateToValue = $j("#dateStart").val();
                //                    var DateFromValue = $j("#dateEnd").val();
                //                
                //                    if (Date.parse(DateToValue) <= Date.parse(DateFromValue)) {
                //                       $j(".alert").text("");
                //                         $j('.sumbitEmp').attr('disabled', false);
                //                    }else{
                //                          $j('.sumbitEmp').attr('disabled', true);
                //                      $j(".alert").text("Chú ý: Ngày hết hạn lớn hơn ngày cấp");
                //                    }
                //                });
            });
            function process(date){
                var parts = date.split("/");
                var date = new Date(parts[1] + "/" + parts[0] + "/" + parts[2]);
                return date.getTime();
            }
        </script>
    </head>

    <style type="text/css">
        #ui-datepicker-div
        {
            z-index: 9999999;
        }
        .lbl_checkbox{
            margin-top: -5px;
        }
    </style>

    <body style=" float:left; width:auto; height:auto; margin:0px;">
        <f:view>
            <f:loadBundle basename="#{environmentSession.localizationSource}" var="locale"/>
            <a4j:form id="personal" >
                <div class="popup" style="height:300px; width:720px">
                    <div class="popup-header">
                        <div class="title"><h:outputText value="#{locale.update_passport}"/> </div>
                    </div>
                    <div class="popup-content">
                        <div class="main_content">
                            <div class="form_item_content labe_short" style="display: block;">
                                <div style="float:left; width:50%;">
                                    <div class="fields_input">
                                        <label class="lbl_checkbox"><h:outputText value="#{locale.identification}"/>*:</label>
                                        <h:selectBooleanCheckbox value="#{n350Controller.nn355c}"  styleClass="checkCmnd" />

                                    </div>
                                    <div class="fields_input">
                                        <label><h:outputText value="#{locale.number}"/>*:</label>
                                        <h:inputText value="#{n350Controller.nv351c}" id="cmnd" styleClass="cmnd required number">

                                        </h:inputText>

                                    </div>
                                    <div class="fields_input fixdate">
                                        <label><h:outputText value="#{locale.date_of_issue}"/>:</label>
                                        <input value="<h:outputText value="#{n350Controller.nd352c}"><f:convertDateTime pattern="dd/MM/yyyy"/></h:outputText>" type="text" id="dateStart" name="dateStart" class="input_fields date" />


                                    </div>
                                    <div class="fields_input">
                                        <label><h:outputText value="#{locale.place_of_issue}"/>:</label>
                                        <h:inputText value="#{n350Controller.nv354c}" styleClass="place_of_issue" />
                                    </div>
                                </div>
                                <div style="float:left; width:49%; border-left: 1px solid #D4D7D8;">
                                    <div class="fields_input">
                                        <label class="lbl_checkbox"><h:outputText value="#{locale.passport}"/>*:</label>
                                        <h:selectBooleanCheckbox value="#{n350Controller.nn355p}"  styleClass="checkPassport"/>

                                    </div>
                                    <div class="fields_input">
                                        <label><h:outputText value="#{locale.number}"/>*:</label>
                                        <h:inputText value="#{n350Controller.nv351p}" id="passport"  styleClass="passport required maxlength" lang="16" >

                                        </h:inputText>

                                    </div>
                                    <div class="fields_input fixdate">
                                        <label><h:outputText value="#{locale.date_of_issue}"/>:</label>
                                        <input  value="<h:outputText value="#{n350Controller.nd352p}"><f:convertDateTime pattern="dd/MM/yyyy"/></h:outputText>" type="text" id="dateStart1" name="dateStart1" class="dateStart1 input_fields date"  />


                                    </div>
                                    <div class="fields_input fixdate">
                                        <label><h:outputText value="#{locale.closing_date}"/>:</label>
                                        <input value="<h:outputText value="#{n350Controller.nd353p}"><f:convertDateTime pattern="dd/MM/yyyy"/></h:outputText>" type="text" id="dateEnd1" name="dateEnd1" class="dateEnd1 input_fields date" />

                                    </div>
                                    <div class="fields_input">
                                        <label><h:outputText value="#{locale.place_of_issue}"/>:</label>
                                        <h:inputText value="#{n350Controller.nv354p}" styleClass="place_of_issue1" />
                                    </div>

                                </div>

                                <%--       <div class="fields_input">
                                           <label><h:outputText value="#{locale.papers}"/>*:</label>
                                           <h:selectOneMenu value="#{n350Controller.nn355}">                                           
                                               <f:selectItem itemLabel="#{locale.identification}" itemValue="1" />
                                               <f:selectItem itemLabel="#{locale.passport}" itemValue="2" />

                                    </h:selectOneMenu>          
                                </div>
                                <div class="fields_input">
                                    <label><h:outputText value="#{locale.number}"/>*:</label>
                                    <h:inputText value="#{n350Controller.nv351}" id="cmnd" styleClass="required maxlength" lang="16">

                                    </h:inputText>

                                </div>
                                <div class="fields_input">
                                    <label><h:outputText value="#{locale.date_of_issue}"/>:</label>
                                    <input value="<h:outputText value="#{n350Controller.nd352}"><f:convertDateTime pattern="dd/MM/yyyy"/></h:outputText>" type="text" id="dateStart" name="dateStart" class="input_fields date"/>


                                    </div>
                                <div class="fields_input">
                                        <label><h:outputText value="#{locale.closing_date}"/>:</label>
                                    <input value="<h:outputText value="#{n350Controller.nd353}"><f:convertDateTime pattern="dd/MM/yyyy"/></h:outputText>" type="text" id="dateEnd" name="dateEnd" class="input_fields date"/>

                                    </div>
                                <div class="fields_input">
                                        <label><h:outputText value="Nơi cấp:"/></label>
                                        <h:inputText value="#{n350Controller.nv354}" id="nc" />

                                    </div>
                                --%>
                            </div>
                            <div class="alert">

                            </div>
                        </div>

                    </div>
                    <div class="popup-footer">

                        <div class="buttonsave" style="margin-right: 35px;" onclick="jQuery.fancybox.close()"><span><h:outputText value="#{locale.close}"/></span></div>
                        <h:commandButton id="sumbitEmp" onclick="return validatecheck('personal');" action="#{n350Controller.saveN350}" value="#{locale.save}" styleClass="buttonsave sumbitEmp">
                        </h:commandButton>
                        <%--  <a4j:commandButton  value='#{locale.save}' actionListener="#{n350Controller.saveN350}"
                                              onclick="return validatecheck('personal');"
                                              styleClass="buttonsave sumbitEmp"  ></a4j:commandButton> --%>
                        <h:inputHidden value="#{n350Controller.stringtab}" id="stringtab"/>
                        <h:inputHidden value="#{n350Controller.pagereload}" id="pagereload"/>
                        <h:inputHidden value="#{n350Controller.fn100}" id="fn100"/>
                        <h:inputHidden value="#{n350Controller.pn350}" id="pn350"/>
                        <h:inputHidden value="#{n350Controller.pn350c}" id="pn350c"/>
                        <h:inputHidden value="#{n350Controller.pn350p}" id="pn350p"/>
                        <h:inputHidden value="#{n350Controller.flagedit}" id="flagedit"/>
                        <h:inputHidden value="#{n350Controller.table1}" id="table1"/>
                    </div>
                </div>
            </a4j:form>
        </f:view>
    </body>
</html>
<script type="text/javascript">
    $j(document).ready(function(){
        yhight = ($j('.popup').height()-90)+"px" ;
        $j('.main_content').css('height',yhight );
        $j('.popup-content').css('height',yhight );
    });
</script>